-
Notifications
You must be signed in to change notification settings - Fork 647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bring SQS Propagation in line with the spec #1673
Conversation
@tsloughter does AWS support x-ray propagation on the message attribute level? I think in the Java instrumentation, the propagation is done via http headers on the outgoing request rather than the request body. I'm not sure if there's a difference in behavior. |
I think context propagation with |
Ah. I thought I saw them in the response body but I guess not. My reading of the SQS spec was that they shouldn't be on regular attributes because of user limits there and instead to use system attributes, but if those aren't propagated to the user that doesn't help :) |
@tylerbenson I went looking and can't find where Java does this for SQS. |
Ah. It does look like Python is doing the same, https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py#L116 So I could instead update that too always use XRay and remove the existing propagation in attributes..? |
Or wait, wouldn't putting it in headers break sending batches? Batches will have messages with separate trace contexts. |
Good question. I don't know the answer to that. In theory we should be doing something similar to what AWS is doing for their sdks: https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-python-patching.html |
@mariojonke I noticed Might that be the value from |
It looks like it is the same thing but i haven't tested it yet. The instrumentation probably would need inject into the Another thing to consider i guess is that the XRay trace header only contains trace ID, span ID and sampling flag. This is more or less in line with the W3C traceparent but it doesn't seem to provide a tracestate or similar. So any vendor specific information will be lost when tracing an SQS message and using the XRay propagator. |
The proposed change will introduce an incompatibility with SNS and SQS tracing scenarios currently in use, that rely on the global propagator being called to inject/extract the context into message attributes. See open-telemetry/opentelemetry-specification#3212 (review) for a more detailed explanation. I therefore suggest to keep the call to the global propagator's inject and extract methods in place and add the X-Ray propagator in a backwards compatible way. |
Experimenting with the x-ray sdk and rereading the existing spec I'll be updating this PR to no longer inject the I still need to get this working with otel python boto and boto3sqs to make sure it works as I expect based on use of x-ray python sdk. I'll be asking about that on slack tomorrow :) I'm not sure what to do about backwards compatibility. |
I'm going to close this and open a new PR only focused on I still think changes are needed to SQS instrumentation, but not the ones in this PR. I'll likely make one in the near future that adds support for checking for |
If you meant setting, this should not actually be needed: If you set the X-Ray HTTP header when sending an SQS message, AWS will automatically fill in the AWSTraceHeader message system attribute based on that. |
@Oberon00 right, it fills it in, but it needs to be checked for on the receiving side. |
Opening as a draft because 1 test still fails. I'm hoping someone more familiar with the code might notice what I did wrong easily :)
The failure is in
TestBoto3SQSInstrumentation.test_receive_message
, no links are found:I did some simple
printf
debugging to check what theMessageSystemAttributes
were before callingextract
and thectx
after callingextract
:And the header is there as expected and it is extracted properly but the ctx is then empty:
message_system_attributes
:Value in
Boto3SQSGetter.get
:ctx
:Description
The instrumentation spec for SQS defines that propagation is done with X-Ray to the key
AWSTraceHeader
inMessageSystemAttributes
. This patch brings the propagation in line with the spec from what it was doing before of using the global propagator andMessageAttributes
.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.